<template>	        
	<view class='main'>
		<view class="mine__bg" style="background-image: url(https://image.workair.top/uplaod/20250618/e9b2bb19f83d071d949c3c9bd21c22136e9f5d91.png);;padding-top: 140rpx;">
			<navbar  :btnColors='btnColor' title="我的钱包" :isGoBack="true" :isNotice="true" :visible="true"></navbar>
			
			<view class="margin-top">
				   <view class="flex ">
				   	   <view class="flex flex-direction money1">
				   	   	   <text style="font-size: 24rpx;color: #555555;">我的押金</text>
						   <text style="font-size: 40rpx;color: #222222;margin-top: 20rpx;">{{userInfo.deposit_price}}</text>
				   	   </view>
					   <view class="middle money2">
					   	  
					   </view>
					   <view class="flex flex-direction money2">
					   	   <text style="font-size: 24rpx;color: #555555;">我的收益</text>
						   <view style="font-size: 24rpx;color: #36B3E9;" class="flex align-center text-center; justify-center">
							   <text style="font-size: 40rpx;">{{userInfo.balance}}</text>
							   <view class="mt-10 ml-10">
							     <u-button text="提现" shape="circle" type="success"   :plain="true"  color="#36B3E9  " size="small" class="ml-20" customStyle="width: 80rpx;height: 58rpx;" @click="docash()" ></u-button>
							   </view>	
							</view>
					   </view>
				   </view>				  
			</view>
			<view class="flex justify-between wallet_info  pl-30 align-center text-center;" @click="bank_list">
			   <view class="flex" style="font-size: 28rpx;color: #555555;">
					<image :src="api_image+'/uplaod/20250618/0a9d6cc8dea9acfdfa7087e2f36e74f8d41622d1.png'" class="wallet" mode="scaleToFill"></image>
					<text class="ml-15">绑定银行卡</text>
			   </view>
			   <view class="" style="padding-right: 32rpx;">
				<image :src="api_image+'/uplaod/20250618/797b4287a5da37b3b36f57ab7fa8fad6817a3a73.png'" class="wallet-right" mode="scaleToFill"></image>
			   </view>			
			</view>			
		</view>		
		
		<view class="list">					
			<view class="node-tab">
				<view class="tab-item"  :class="[currentTab == 0 ? 'active' : '']" :data-current="0" @click="changeNav">押金记录</view>
				<view class="tab-item"  :class="[currentTab == 1 ? 'active' : '']" :data-current="1" @click="changeNav">收益明细</view>
			</view>	
			
                <swiper class="tab-content"  duration="300" bindchange="changeTab" :style="{'height':winHeight+'px'}">
					<!-- 全部 -->
					<swiper-item>
						<scroll-view :scroll-y="true" class="new-list-box" @scrolltolower="allLoadMore" scroll-top="scrollTop" scroll-with-animation :refresher-enabled="true" refresher-threshold="80" refresher-default-style="white" refresher-background="white" :refresher-triggered="triggered" @refresherrefresh="onAllRefresh">
							<block v-if="allTabList.length > 0">
								<view class="new-list-item border-b mt-10" v-for="(item,index) in allTabList" :key="index" style="width: 100%;">                        
									<view class="item-tag dis-flex-between">     
										<view class="content-deadline" style="color: #222222;font-size: 32rpx;">类型：{{item.info}}</view>     
										<view class="content-deadline text-xsl mt-20" style="color: #888888;">交易时间：{{item.add_time}}</view>										                       
									</view>
									<view class="item-tag dis-flex-between text-right">
									  <view class="content-deadline text-bold" style="color: #36B3E9;" v-if="item.style==1">+{{item.affectMoney}}</view>
									   <view class="content-deadline text-bold" style="color: red;"  v-if="item.style==0">-{{item.affectMoney}}</view>
									  <view class="content-deadline mt-20" style="color: #888888;">{{item.info}}</view>
								  </view>
								</view>
							</block>                
						</scroll-view>
					</swiper-item>       
				</swiper>	
			 
		</view>
	</view>		
</template>
<script>
	export default {		
		data() {
			return {
				...getApp().globalData.config,
				userInfo:{},
				winHeight:0,
				pageNo:1,
				allTabList:[], // 全部  
				currentTab: 0, // 当前所在滑块的 index
				scrollTop: 0, // 设置竖向滚动条位置
				triggered: false, // 下拉是否激活
			};
		},
		onShow(){			
		   this.userInfo=uni.getStorageSync('userInfo')
		   this.queryUser()
		},
		onLoad(options){
			let that=this
			if(options.cashType){
			  this.cashType=options.cashType			  
			}
			if(options.currentTab==1){
				this.currentTab=1
			}
			let height = uni.getSystemInfoSync().windowHeight;
			this.winHeight = (height - 360);			
			this._requestPageList(true);
		},	
		methods:{
			//用户信息
			queryUser(){
				let that=this;
				let obj_data={
					token:uni.getStorageSync('userInfo').token,
				};
				this.$http.getUser(obj_data).then(res=>{				
					if(res.resCode=='9999'){
					    that.userInfo=res.data											
					}				
				})			
			},
			
			//银行卡
			bank_list(){
				this.$routers.router('/pages/pagesuser/bankList/index','navigateTo') 
			},
			changeNav(e){
				let currentIndex = e.target.dataset.current;				
				this.pageNo=1;
				this.currentTab= currentIndex				
				this.allTabList=[];
				this._requestPageList(true);
			},	
			// 参数
			_requestPageList(isLoadMore = false, callback) {
			  if(!isLoadMore){
				this.allTabList=[]; // 全部       
				this.pageNo= 1;
				
			  }
			  let opt = {
				pageNo :this.pageNo,				
				token:uni.getStorageSync('userInfo').token,
				status:this.currentTab
			  }    
			  this._requestPageListCom("virtualTaskList", opt, callback);
			},
			// 列表接口
			_requestPageListCom(url, params, callback) {    
			  this.$http.moneylog_list(params).then(res => {
				if (res.resCode == "9999") {
				  let oldList = [];
				  oldList = this.allTabList;       
				  const newGoodsList = res.data.list
				  const allData = [...oldList, ...newGoodsList]
				  // console.log(allData,'allData')     
				  this.allTabList=allData
				  if(callback && typeof callback === 'function'){
					callback()
				  }
				}
			  })
			},			  
			// 上拉加载  滚动到底部/右边时触发
			allLoadMore(e){
				let _self = this;
				if (this._allLoadMore) return
				this._allLoadMore = true;
				this.pageNo= ++_self.pageNo				
				this._requestPageList(true, () => {
				  _self._allLoadMore = false;
				});
			},
			
			// 下拉刷新接口
			onAllRefresh() {
			 // 开启下拉自定义样式
				this.triggered = true;
			    this.pageNo=1;
				this._requestPageList(false, () => {
					// 当处理完数据刷新后，wx.stopPullDownRefresh可以停止当前页面的下拉刷新
					this.triggered = false;
				});    
			},
			//提现
			docash(){
				this.$routers.router('/pages/pagesuser/docash_draw/index','navigateTo') 
			}
		}
	}
</script>
<style>
	@import "./index.css";
</style>